package com.t235.gc.order.service.impl;

import com.t235.gc.entity.HomeRecyclingDetailOrder;
import com.t235.gc.dao.HomeRecyclingDetailOrderDao;
import com.t235.gc.order.service.HomeRecyclingDetailOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 上门回收详情订单表(HomeRecyclingDetailOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:33
 */
@Service("homeRecyclingDetailOrderService")
public class HomeRecyclingDetailOrderServiceImpl implements HomeRecyclingDetailOrderService {
    @Resource
    private HomeRecyclingDetailOrderDao homeRecyclingDetailOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param detailorderid 主键
     * @return 实例对象
     */
    @Override
    public HomeRecyclingDetailOrder queryById(Long detailorderid) {
        return this.homeRecyclingDetailOrderDao.queryById(detailorderid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<HomeRecyclingDetailOrder> queryAllByLimit(int offset, int limit) {
        return this.homeRecyclingDetailOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param homeRecyclingDetailOrder 实例对象
     * @return 实例对象
     */
    @Override
    public HomeRecyclingDetailOrder insert(HomeRecyclingDetailOrder homeRecyclingDetailOrder) {
        this.homeRecyclingDetailOrderDao.insert(homeRecyclingDetailOrder);
        return homeRecyclingDetailOrder;
    }

    /**
     * 修改数据
     *
     * @param homeRecyclingDetailOrder 实例对象
     * @return 实例对象
     */
    @Override
    public HomeRecyclingDetailOrder update(HomeRecyclingDetailOrder homeRecyclingDetailOrder) {
        this.homeRecyclingDetailOrderDao.update(homeRecyclingDetailOrder);
        return this.queryById(homeRecyclingDetailOrder.getDetailorderid());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailorderid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long detailorderid) {
        return this.homeRecyclingDetailOrderDao.deleteById(detailorderid) > 0;
    }
}
